import React, { Component } from 'react'
import { Button, InputItem } from 'antd-mobile'
import { createForm } from 'rc-form'

import '../../sass/login.sass'

class login extends Component {
  change = () => {
    // rc-form 的表单验证,需要安装 rc-form 依赖
    this.props.form.validateFields((error, value) => {
      console.log(error, value);
    });
    this.props.history.push(`/main/mainIndex`)
  }
  handleClick = () => {
    this.inputRef.focus()
  }
  render() {
    const { getFieldProps } = this.props.form
    return (
      <div className="login">
        <InputItem
          {...getFieldProps('name')}
          placeholder="请输入账号"
          clear
          maxLength="12"
        >
          账号
        </InputItem>
        <InputItem
          {...getFieldProps('password')}
          type="password"
          placeholder="******"
          clear
          maxLength="20"
        >
          密码
        </InputItem>
        <Button type="primary" className="loginBtn" onClick={this.change}>
          登陆
        </Button>
      </div>
    )
  }
}
const Login = createForm()(login)
export default Login
